home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / pdox35sc.zip / BACKUP.SC next >
Text File  |  1991-06-10  |  26KB  |  356 lines

  1. ; ***************************************************************************************
  2. ;                           BACKING UP DATA TO A FLOPPY DISK
  3.  
  4. ; Copyright 1991   Virginia B. Sauer   All Rights Reserved
  5. ; This program may be copied/modified without charge provided both that this
  6. ; copyright notice is included without change, and that any accompanying
  7. ; documentation includes the notice "Portions of code (c) Copyright 1991,
  8. ; Virginia B. Sauer"
  9. ; ***************************************************************************************
  10.  
  11. ;  Failure to back up data has caused countless corporations to lose critical information.
  12. ;  In many instances, the problem is that of ignorance:  novices forget the necessary
  13. ;  commands, and are either too busy or too embarrassed to request assistance.
  14.  
  15. ;  To forestall such problems, the following utility has been developed to walk the user
  16. ;  through automatically formatting a floppy disk and/or copying the respective files to
  17. ;  the diskette.
  18.  
  19. ;  As this is completely generic, it can effortlessly be incorporated into any application
  20. ;  you design.
  21.  
  22. ; ───────────────────────────────────────────────────────────────────────────────────────
  23. ;               *************** I M P O R T A N T   N O T E ***************
  24.  
  25. ;  To invoke this procedure, you will also need to create a file named Backup.Txt,
  26. ;  comprised of three lines of code:
  27. ;                                             (one blank line)
  28. ;                              N              (the letter N)
  29. ;                              ^Z             (Ascii character 26)
  30.  
  31. ;  (This is to ensure a complete user-friendly, menu-driven application by bypassing DOS
  32. ;  questions when the diskette is being formatted.)
  33. ; ───────────────────────────────────────────────────────────────────────────────────────
  34.  
  35. ; ╔══════════════════════════════════════════════════════════════════════════════════════╗
  36. ; ║                        PARAMETERS  PASSED  TO  THIS  PROCEDURE                       ║
  37. ; ╟──────────┬───────────────────────────────────────────────────────┬───────────────────╢
  38. ; ║ ARGUMENT │                      DESCRIPTION                      │      SAMPLE       ║
  39. ; ╟──────────┼───────────────────────────────────────────────────────┼───────────────────╢
  40. ; ║          │  1 - 14 character name/abbreviation of your           │                   ║
  41. ; ║          │  application (e. g., "Testing", to signify a          │     "Testing"     ║
  42. ; ║SystemName│  system named Testing)                                │                   ║
  43. ; ║          │                                                       │  (To signify a    ║
  44. ; ║          │  N. B.  Unless this is a variable, it must be         │  testing system)  ║
  45. ; ║          │         enclosed in quotes.                           │                   ║
  46. ; ╟──────────┼───────────────────────────────────────────────────────┼───────────────────╢
  47. ; ║          │  The files to be copied ... e. g., "ALL", to copy     │                   ║
  48. ; ║          │  all files in the specified directory, or "AR", to    │     "ALL"         ║
  49. ; ║          │  copy only those with the prefix "AR" (for Archive)   │                   ║
  50. ; ║          │                                                       │                   ║
  51. ; ║WhichFiles│  Obviously, this segment of code can be modified      │   (To copy all    ║
  52. ; ║          │  to reflect your own naming conventions.              │   files in the    ║
  53. ; ║          │                                                       │   specified       ║
  54. ; ║          │  N. B.  Unless this is a variable, it must be         │   directory)      ║
  55. ; ║          │         enclosed in quotes.                           │                   ║
  56. ; ╟──────────┼───────────────────────────────────────────────────────┼───────────────────╢
  57. ; ║          │                                                       │ "C:\\TPTS\\DATA"  ║
  58. ; ║          │  The full path of the directory containing the files  │                   ║
  59. ; ║          │  to be copied (using double backslashes to separate   │ (To signify       ║
  60. ; ║          │  drive, directory, and subdirectory) - e. g.,         │ Drive C, Direc-   ║
  61. ; ║          │  "C:\\TPTS\\Data" if the files are located in Drive   │ tory TPTS, Sub-   ║
  62. ; ║          │  C, Directory TPTS, SubDirectory Data                 │ Directory Data)   ║
  63. ; ║          │                                                       │                   ║
  64. ; ║          │  Should you prefer to default to the user's current   │      -or-         ║
  65. ; ║ WhichDir │  directory, either eliminate this argument, or sub-   │                   ║
  66. ; ║          │  stitute a variable for the directory path (e. g.,    │    CurrDir        ║
  67. ; ║          │  CurrDir, for Current Directory) and declare the      │                   ║
  68. ; ║          │  variable before invoking the procedure:              │ (to signify var-  ║
  69. ; ║          │        CurrDir = Directory()                          │ iable CurrDir,    ║
  70. ; ║          │                                                       │ which must then   ║
  71. ; ║          │  N. B.  Unless this is a variable, it must be         │ be declared be-   ║
  72. ; ║          │         enclosed in quotes.                           │ fore calling the  ║
  73. ; ║          │                                                       │ procedure)        ║
  74. ; ╟──────────┼───────────────────────────────────────────────────────┼───────────────────╢
  75. ; ║          │  The type of PC being used ("AT", "XT", "386", or     │                   ║
  76. ; ║          │  "Laptop")                                            │                   ║
  77. ; ║          │                                                       │                   ║
  78. ; ║          │  Unfortunately, many clones fail to specify class -   │       "AT"        ║
  79. ; ║          │  and most beginners have no idea what they are        │                   ║
  80. ; ║  PCType  │  using.  When in doubt, it is therefore prudent to    │                   ║
  81. ; ║          │  have applications default to "XT", since double      │    (to specify    ║
  82. ; ║          │  density diskettes can also be used by ATs.           │    an AT)         ║
  83. ; ║          │                                                       │                   ║
  84. ; ║          │  N. B.  Unless this is a variable, it must be         │                   ║
  85. ; ║          │         enclosed in quotes.                           │                   ║
  86. ; ╟──────────┼───────────────────────────────────────────────────────┼───────────────────╢
  87. ; ║          │  The drive in which the diskette is to be placed      │                   ║
  88. ; ║          │  (e. g., "A", to signify drive A)                     │       "A"         ║
  89. ; ║  WhereTo │                                                       │                   ║
  90. ; ║          │  N. B.  Unless this is a variable, it must be         │   (to signify)    ║
  91. ; ║          │         enclosed in quotes.                           │    Drive A)       ║
  92. ; ╚══════════╧═══════════════════════════════════════════════════════╧═══════════════════╝
  93.  
  94.  
  95. ;----------Check whether or not the specified drive is ready
  96. Proc Check_TargetDrive()  ;---Check whether or not the specified drive is ready
  97.    Private Keypressed
  98.    Cursor off
  99.    Clear Clearall
  100.    Paintcanvas Attribute 00 00, 00, 24, 79 Style attribute 15 ; black
  101.    If not Drivestatus(Whereto) ; Apprise user if drive is not ready
  102.       Then Paintcanvas Attribute 63 03, 11, 21, 64 Style Attribute 63 ; White on cyan
  103.            @ 03,11 ?? Fill("\223",53)                                 ; Use Ascii
  104.            @ 21,11 ?? Fill("\220",53)                                 ; characters
  105.            For X From 2 TO 20                                         ; to create frame:
  106.               @ (X+1), 11 ?? "\219"                                   ; 223 ▀
  107.               @ (X+1), 64 ?? "\219"                                   ; 219 █
  108.            EndFor                                                     ; 220 ▄
  109.            @ 11,15 ?? "Please make sure that the diskette is placed"
  110.            @ 12,15 ?? "in your computer's floppy drive " + Upper(Whereto) + ".  Pull"
  111.            @ 13,15 ?? "down the lever at the top of the floppy"
  112.            @ 14,15 ?? "drive (or, if there is no lever, make"
  113.            @ 15,15 ?? "certain the diskette is firmly in place)."
  114.            Style Attribute 15                            ; white on black
  115.            @  6,20 ?? "\219", Fill("\223",36), "\219"    ; Use Ascii characters to
  116.            @  7,20 ?? "\219", Fill(" ",36),    "\219"    ; create box:
  117.            @  8,20 ?? "\219", Fill("\220",36), "\219"    ; 223 = ▀, 219 = █,  220 = ▄
  118.            Style attribute 03
  119.            @ 18,26 ?? "Press any key when ready."
  120.            Style attribute 139                           ; blinking text
  121.            @ 07,27 ?? "DRIVE " + Upper(Whereto) + " IS NOT READY !!!"
  122.            Keypressed = Getchar()
  123.    Endif
  124. Endproc
  125.  
  126. Proc Backup_Data(SystemName,WhichFiles,WhichDir,PCType,WhereTo)
  127.    Private Density,       ; Density of diskette (determined by argument PCType)
  128.            Header,        ; Heading (determined by argument SystemName)
  129.            YN             ; Whether or not user wants diskette formatted
  130.  
  131.    ;--------------------------------------------------------------------------------------
  132.    ; Determine disk size and density (to instruct user what is needed for his PC)
  133.    ;--------------------------------------------------------------------------------------
  134.    Switch
  135.       Case Upper(PCType) = "AT"
  136.         or Upper(PCType) = "386"    : Disksize = "5 1/4"
  137.                                       Density  = "high"
  138.       Case Upper(PCType) = "XT"     : Disksize = "5 1/4"
  139.                                       Density  = "double"
  140.       Case Upper(PCType) = "LAPTOP" : Disksize = "3 1/2"
  141.                                       Density  = "double"
  142.    Endswitch
  143.  
  144.    ;--------------------------------------------------------------------------------------
  145.    ; Draw frame
  146.    ;--------------------------------------------------------------------------------------
  147.    Clear Clearall
  148.    Paintcanvas Attribute 00 00, 00, 24, 79 Style Attribute 15 ; Draw black canvas
  149.    Paintcanvas Attribute 63 01, 03, 24, 75                    ; white on cyan
  150.    @ 00,03 ?? Fill("\220",74)                                 ; Use Ascii
  151.    @ 24,03 ?? Fill("\223",74)                                 ; characters
  152.    For X From 0 TO 22                                         ; to create frame:
  153.       @ (X+1), 03 ?? "\219"                                   ; 223 ▀
  154.       @ (X+1), 76 ?? "\219"                                   ; 219 █
  155.    EndFor                                                     ; 220 ▄
  156.  
  157.    ;--------------------------------------------------------------------------------------
  158.    ; Provide step-by-step instructions (based on user's type of PC, et cetera)
  159.    ;--------------------------------------------------------------------------------------
  160.    Style Attribute 48                                       ; black on cyan
  161.    @  7,10 ?? "You will need a formatted "+DiskSize+"-inch double-sided, "+Density+"-"
  162.    @  8,10 ?? "density diskette (floppy disk)."
  163.    @ 10,10 ?? "Holding the diskette at the top (so that the manufacturer's"
  164.    @ 11,10 ?? "label is to the right, and the write-protect notch is to the"
  165.    @ 12,10 ?? "left), place it in your computer's floppy drive "+ Upper(WhereTo) +"."
  166.    @ 14,10 ?? "Pull down the lever at the top of the floppy drive.  (If"
  167.    @ 15,10 ?? "there is no lever, make certain that the diskette is firmly"
  168.    @ 16,10 ?? "in place.)"
  169.  
  170.    ;--------------------------------------------------------------------------------------
  171.    ; Ask user whether or not the diskette must be formatted
  172.    ;--------------------------------------------------------------------------------------
  173.    Style attribute 63                                       ; White on cyan
  174.    @ 18,21 ?? "Does this diskette need to be formatted?"
  175.  
  176.    ;--------------------------------------------------------------------------------------
  177.    ; Center the heading within a small box at the top of the screen
  178.    ; (Modify the spacing for Header if your system name exceeds 14 characters.)
  179.    ;--------------------------------------------------------------------------------------
  180.    Style Attribute 15                            ; white on black
  181.    @  2,13 ?? "\219", Fill("\223",52), "\219"    ; Use Ascii characters to
  182.    @  3,13 ?? "\219", Fill(" ",52),    "\219"    ; create box:
  183.    @  4,13 ?? "\219", Fill("\220",52), "\219"    ; 223 = ▀, 219 = █,  220 = ▄
  184.    Style Attribute 11                            ; light cyan on black
  185.    Header = "BACKING   UP   " + Upper(SystemName) + "   SYSTEM   RECORDS"
  186.    @ 3,16 ??  Format("AC,CU,W48",Strval(Header))
  187.  
  188.    ;--------------------------------------------------------------------------------------
  189.    ; Instruct user to press enter key when finished, or escape key to quit
  190.    ;--------------------------------------------------------------------------------------
  191.    Style Attribute 03                            ; cyan on black
  192.    @ 22,14 ?? "Press the <Enter> key when finished (or <Esc> to quit)."
  193.    Style Attribute 15                            ; white on black
  194.    @ 20,26 ?? "Please answer Yes or No:   "      ; relates to the above question
  195.    Style Attribute 11 Accept "A3" Required picture "{YES,NO}" to YN
  196.  
  197.    ;--------------------------------------------------------------------------------------
  198.    ; Return if user pressed Escape key ... Otherwise, let him know when diskette is
  199.    ; being formatted, et cetera
  200.    ;--------------------------------------------------------------------------------------
  201.    If retval = False                             ; Return if user pressed escape key
  202.       Then return
  203.       ;-----------------------------------------------------------------------------------
  204.       ; If the diskette must be formatted, apprise user.
  205.       ; Use Run NoRefresh commands to leave canvas in view while shelling to DOS.
  206.       ; As explained above, to avoid confusing novices with DOS questions, create a
  207.       ;    file named Backup.Txt, consisting of three lines of code:
  208.       ;                          (one blank line)
  209.       ;       N                  (the letter N)
  210.       ;       \26                (\26, to denote Ascii character 26)
  211.       ;    (<Backup.Txt then tells DOS to follow the directions in this file.)
  212.       ; Add >Nul to instruct DOS not to confuse the user by displaying messages.
  213.       ;-----------------------------------------------------------------------------------
  214.       Else Check_TargetDrive()                           ; ensure that target drive is ready
  215.            If YN = "YES"
  216.               Then Please_Wait("Please wait while the diskette is being formatted.")
  217.                    Run NoRefresh "Format " + WhereTo + ": <Backup.Txt >Nul"
  218.            Endif
  219.            Please_Wait("Please wait until light goes out and you hear a beep")
  220.            ;------------------------------------------------------------------------------
  221.            ; Shell to DOS to copy the designated files to the diskette.  (In this
  222.            ; case, use Run Big in case many large files are involved.)
  223.            ; If necessary, modify the following segment of code to reflect your own
  224.            ; naming conventions - e. g., to copy a table named orders:
  225.            ;    Case Upper(WhichFiles) = "ORDERS" : WhichFiles = "ORDERS"
  226.            ;------------------------------------------------------------------------------
  227.            If not Match(WhichDir,"..\\")                             ; Missing trailing
  228.               then WhichDir = WhichDir + "\\"                        ; Backslash
  229.            Endif
  230.            If Upper(Whichfiles) = "ALL"                              ; Establish which
  231.               Then WhichFiles = ""                                   ; files are copied
  232.            Endif
  233.            WhichFiles = WhichDir + WhichFiles + "*.db "
  234.            Run Big NoRefresh "Copy " + WhichFiles                    ; Copy designated
  235.                             + WhereTo + ":>Nul"                     ; files to diskette
  236.    Endif
  237.    Beep                    ; Beep to advise user that backup is finished
  238. Endproc
  239.  
  240. ; ╔══════════════════════════════════════════════════════════════════════════════════════╗
  241. ; ║                                    EXAMPLE(S)                                        ║
  242. ; ║                                                                                      ║
  243. ; ║   To be invoked AFTER creating a file named Backup.Txt consisting of three lines     ║
  244. ; ║   of code:                                                                           ║
  245. ; ║                          (one blank line)                                            ║
  246. ; ║            N             (the letter N)                                              ║
  247. ; ║            \26           (\26, to denote Ascii character 26)                         ║
  248. ; ║                                                                                      ║
  249. ; ╟──────────────────────────────────────────────────────────────────────────────────────╢
  250. ; ║                                                                                      ║
  251. ; ║  (1)   If copying all files of a system named "Testing" from subdirectory Data of    ║
  252. ; ║        Directory TPTS (Drive C) of an AT to a floppy disk in drive A:                ║
  253. ; ║                                                                                      ║
  254. ; ║               Backup_Data("Testing","All","C:\\TPTS\\Data","AT","A")                 ║
  255. ; ║                                                                                      ║
  256. ; ╟──────────────────────────────────────────────────────────────────────────────────────╢
  257. ; ║                                                                                      ║
  258. ; ║  (2)   If copying all Purchasing System files with the prefix "AR" from the current  ║
  259. ; ║        directory of an XT to a floppy disk in drive B:                               ║
  260. ; ║                                                                                      ║
  261. ; ║               CurrDir = Directory()                                                  ║
  262. ; ║                                                                                      ║
  263. ; ║               Backup_Data("Purchasing","AR",CurrDir,"XT","B")                        ║
  264. ; ║                                                                                      ║
  265. ; ╚══════════════════════════════════════════════════════════════════════════════════════╝
  266.  
  267.  
  268. ; ╔══════════════════════════════════════════════════════════════════════════════════════╗
  269. ; ║                                   VARIATION(S)                                       ║
  270. ; ╟──────────────────────────────────────────────────────────────────────────────────────╢
  271. ; ║                                                                                      ║
  272. ; ║  (1)   If the files are likely to outgrow one diskette, a compression utility        ║
  273. ; ║        should be incorporated.                                                       ║
  274. ; ║                                                                                      ║
  275. ; ║        Make certain that you obtain the proper licenses (e. g., for runtime          ║
  276. ; ║        versions or systems to be distributed to other users).                        ║
  277. ; ║                                                                                      ║
  278. ; ║        Replace "Run Big Copy..." with the respective commands for the archiving      ║
  279. ; ║        utility you have selected - e. g., if using ARC:                              ║
  280. ; ║             Run Big NoRefresh "Arc A A:\\TestArch.Arc " + WhichFiles                 ║
  281. ; ║                                + WhereTo + ":>Nul"                                   ║
  282. ; ║                                                                                      ║
  283. ; ╟──────────────────────────────────────────────────────────────────────────────────────╢
  284. ; ║                                                                                      ║
  285. ; ║  (2)   When creating runtime applications, it is patently impossible to know the     ║
  286. ; ║        hardware and software under which they will run.                              ║
  287. ; ║                                                                                      ║
  288. ; ║        The system's main menu should therefore include a "change configurations"     ║
  289. ; ║        option to enable users to designate their printers, type of PC, et cetera.    ║
  290. ; ║                                                                                      ║
  291. ; ╟──────────────────────────────────────────────────────────────────────────────────────╢
  292. ; ║                                                                                      ║
  293. ; ║  (3)   Obviously, these procedures can be modified to accomodate tape backup         ║
  294. ; ║        systems.  As in the case of archive utilities, simply substitute the          ║
  295. ; ║        appropriate commands, and modify the on-screen directives accordingly.        ║
  296. ; ║                                                                                      ║
  297. ; ╚══════════════════════════════════════════════════════════════════════════════════════╝
  298.  
  299.  
  300.  
  301. ; ***************************************************************************************
  302. ;             SHOW MESSAGE TO PREVENT IMPATIENT USERS FROM WREAKING HAVOC
  303. ;   (A generic procedure utilized by backup procedure, but useful in any application.)
  304. ; ***************************************************************************************
  305.  
  306.  
  307. ; ╔══════════════════════════════════════════════════════════════════════════════════════╗
  308. ; ║                        PARAMETERS  PASSED  TO  THIS  PROCEDURE                       ║
  309. ; ╟──────────┬───────────────────────────────────────────────────────────────────────────╢
  310. ; ║ ARGUMENT │                      DESCRIPTION                                          ║
  311. ; ╟──────────┼───────────────────────────────────────────────────────────────────────────╢
  312. ; ║          │                                                                           ║
  313. ; ║          │  Message of up to 52 characters, apprising user that program is running,  ║
  314. ; ║          │  and/or what is expected of him:                                          ║
  315. ; ║          │                                                                           ║
  316. ; ║          │   e. g., "Please wait while the information is being processed"           ║
  317. ; ║          │                                                                           ║
  318. ; ║ WaitMssg │          "Please wait until light goes out and you hear a beep"           ║
  319. ; ║          │                                                                           ║
  320. ; ║          │          "Please wait while the records are being extracted"              ║
  321. ; ║          │                                                                           ║
  322. ; ║          │                                                                           ║
  323. ; ║          │   N. B.  Unless the message, itself, is a variable, this must be          ║
  324. ; ║          │          enclosed in quotes.                                              ║
  325. ; ║          │                                                                           ║
  326. ; ╚══════════╧═══════════════════════════════════════════════════════════════════════════╝
  327.  
  328.  
  329. Proc Please_Wait(WaitMssg)
  330.    Cursor Off                                        ; Do not show cursor
  331.    Clear Clearall                                    ; Clear screen and canvas
  332.    PaintCanvas Attribute 00  00, 00, 24, 79          ; Draw black background
  333.    PaintCanvas Attribute 112 10, 07, 14, 75          ; Draw grey shadow
  334.    PaintCanvas Attribute 48  09, 04, 13, 73          ; Draw cyan box
  335.    Style Attribute 176                               ; Draw blinking black characters
  336.    @ 11,05 ??  " \07 \07 \07 "                       ; (Ascii code 7)
  337.    @ 11,66 ??  " \07 \07 \07 "                       ; (Ascii code 7)
  338.    Style Attribute 48                                ; Show black lettering
  339.    @ 11,13 ?? Format("AC,CC,W52",Strval(Waitmssg))   ; Center message (capitalizing
  340. Endproc                                              ; first letter of each word)
  341.  
  342.  
  343.  
  344. ; ╔══════════════════════════════════════════════════════════════════════════════════════╗
  345. ; ║                                      EXAMPLE                                         ║
  346. ; ╟──────────────────────────────────────────────────────────────────────────────────────╢
  347. ; ║                                                                                      ║
  348. ; ║        To show the message, "Please Wait While Information Is Being Computed":       ║
  349. ; ║                 Please_Wait("Please wait while information is being computed")       ║
  350. ; ║                                                                                      ║
  351. ; ║     (The procedure will automatically capitalize the first letter of each word.      ║
  352. ; ║     Should you prefer to capitalize the entire message, replace "CC" with "CU"       ║
  353. ; ║     in the format command.)                                                          ║
  354. ; ║                                                                                      ║
  355. ; ╚══════════════════════════════════════════════════════════════════════════════════════╝
  356.